package com.mxpio.erp.common.equipment.entity;

import com.mxpio.erp.common.equipment.vo.VEquipmentStockInventory;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.persistence.*;

/**
 * @Description: 出库记录
 * @Author: MxpIO
 * @Date:   2021-10-14
 * @Version: V1.0
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "MB_ERP_EQUIPMENT_STOCK_CK_HISTORY")
@Schema(description="入库申请")
public class EquipmentStockCkHistory extends BaseEntity {
    private static final long serialVersionUID = 1L;

	/**id*/
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;
	/**isDel*/
    @Column(name = "IS_DEL_")
    @Schema(description = "isDel")
    private Integer isDel;
	/**版本*/
    @Column(name = "VERSION_")
    @Schema(description = "版本")
    private Integer version;
	/**本次出库数量*/
    @Column(name = "CURRENT_OUT_NUMBER_")
    @Schema(description = "本次出库数量")
    private Integer currentOutNumber;
	/**仓库*/
	@Dict(dicEntity =EquipmentStock.class, dicText = "stockName", dicCode = "id")
    @Column(name = "STOCK_ID_")
    @Schema(description = "仓库ID")
    private String stockId;
	/**备品*/
	@Dict(dicEntity = EquipmentMaterial.class, dicText = "name", dicCode = "id")
    @Column(name = "MATERIALS_ID_")
    @Schema(description = "备品")
    private String materialsId;
	/**出库单ID*/
    @Column(name = "CK_APPLY_ID_")
    @Schema(description = "出库单ID")
    private String ckApplyId;
	/**出库单详情ID*/
    @Column(name = "CK_APPLY_ITEM_ID_")
    @Schema(description = "出库单详情ID")
    private String ckApplyItemId;
	/**货架ID*/
    @Column(name = "SHELF_ID_")
    @Schema(description = "货架ID")
    private String shelfId;
	/**库存信息ID*/
    @Column(name = "INVENTORY_ID_")
    @Schema(description = "库存信息ID")
    private String inventoryId;
    /**操作类型*/
    @Column(name = "TYPE_")
    @Schema(description = "操作类型")
    private Integer type;

    @Transient
    private String optType;

	public EquipmentStockCkHistory(EquipmentStockCkApplyItem ckApplyItem, VEquipmentStockInventory inventoryVo, int type){
        this.isDel = 0;
        this.version = 0;
        this.currentOutNumber = inventoryVo.getOutNumber();
        this.stockId = inventoryVo.getStockId();
        this.materialsId = inventoryVo.getMaterialsId();
        this.ckApplyId = ckApplyItem.getCkApplyId();
        this.ckApplyItemId = ckApplyItem.getId();
        this.inventoryId = inventoryVo.getId();
        this.type = type;
    }
    public EquipmentStockCkHistory(EquipmentStockCkApplyItem ckApplyItem, int type){
        this.isDel = 0;
        this.version = 0;
        this.materialsId = ckApplyItem.getMaterialsId();
        this.ckApplyId = ckApplyItem.getCkApplyId();
        this.ckApplyItemId = ckApplyItem.getId();
        this.type = type;
    }
}
